<?php
$this->breadcrumbs=array(
	'Products'=>array('index'),
	$model->pro_id=>array('view','id'=>$model->pro_id),
	'Update',
);

$this->menu=array(
	array('label'=>'List Product', 'url'=>array('index')),
	array('label'=>'Create Product', 'url'=>array('create')),
	array('label'=>'View Product', 'url'=>array('view', 'id'=>$model->pro_id)),
	array('label'=>'Manage Product', 'url'=>array('admin')),
);
?>

<?php 

	$cs = Yii::app()->getClientScript();
	$url=CHtml::asset(Yii::getPathOfAlias('system.web.widgets.pagers.pager').'.css');
	$cs->registerCssFile($url);

	$updateurl = $this->createUrl('product/update',array('id'=>$_GET['id']));
	
	$ready = <<<READY
		load();	


	$("#product_submit").click(function(){
		$.post('{$updateurl}',{	
//				'Product[pro_id]':$("#Product_pro_id").val(),
				'Product[pro_name]':$("#Product_pro_name").val(),
				'Product[pro_price]':$("#Product_pro_price").val(),
				'Product[pro_cid]':$("#Product_pro_cid").val(),
				'Product[pro_left]':$("#Product_pro_left").val(),
				'Product[pro_sold]':$("#Product_pro_sold").val(),
				'Product[pro_iscomment]':$("#Product_pro_iscomment").val(),
				'Product[pro_status]':$("#Product_pro_status").val(),
				'Product[pro_discount]':$("#Product_pro_discount").val(),
				'Product[pro_describe]':$("#Product_pro_describe").val(),
				'Product[pro_recommend]':$("#Product_pro_recommend").val(),
	
			},function(msg){
//				$(".column2:last").html(msg);
				if(msg == 'ok'){				
					$.msgbox({
				            height:100,
				            width:250,
				            content:{type:'alert', content:'数据更新成功！'},
				            animation:4,
				            onClose:function(v){
				                if(v){			                       
	                  				location.reload(true);
				                }
				                
				            }
				    });   					
					
				}
				

				

		});	
	});

	

	
READY;

	$head = <<<HEAD
	function load(){
		$.get('{$this->createUrl('file/index',array('r'=>time()))}',{'id':{$_GET['id']}},function(msg){
			$("#product-list").html(msg);
		});
	}	
	

	function func_update(id){
		var object = id.parent().siblings(".thumbnail");
		var src = id.attr("id");

		$.colorbox({iframe:true, innerWidth:425, innerHeight:444,href:src,onClosed:function(){ load(); }});
		
	}
	
	function func_trash(id){
		var object = id.parent().siblings(".thumbnail");
		var id = object.find("a").attr("id");
		
		$.get('{$this->createUrl('file/trash')}',{'id':id},function(msg){
			load();
		});	
	}
	
	function func_folder(id){
		var object = id.parent().siblings(".thumbnail");
		var id = object.find("a").attr("id");
		
		var src = object.find("img").attr("src");
		$("#pro_pic_id").attr("src",src);
	
		$.get('{$this->createUrl('folder',array('id'=>$_GET['id'],'rn'=>time()))}',{'fid':id},function(msg){
			if(msg == "ok"){
				$.msgbox({
					height:100,
				    width:250,
				    content:{type:'alert', content:'封面设置成功！'},
				    animation:4

				}); 				
			}

			
		});	
	}
	
	function func_show(id){
	
		var object = id.parent().siblings(".thumbnail");
		var src = object.find("img").attr("src");
		src = src.replace('_thumb','');
		$.colorbox({href:src,slideshow:true, height:500});
		return false;
	}
	
	function func_showImg(id){
	
		var src = id.attr("name");
		$.colorbox({href:src});
		return false;
	}
	
	function func_showInfo(id){
		var src = id.attr("name");
		$.colorbox({iframe:true, innerWidth:425, innerHeight:444,href:src});
		return false;
	}

HEAD;
?>
<?php Yii::app()->getClientScript()->registerScript('file-index-ready',$ready,CClientScript::POS_READY);?>
<?php Yii::app()->getClientScript()->registerScript('file-index-head',$head,CClientScript::POS_HEAD);?>
<div class="column1">
	<div class="box">
		<?php $this->beginWidget('zii.widgets.CPortlet', array('title'=>'Update Product Info',	));?>
			<div class="box-content">	
			<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>
			</div>
		<?php $this->endWidget();?>
	</div>
</div>
<div class="column2">	
	<div class="box">
		<?php $this->beginWidget('zii.widgets.CPortlet', array(	'title'=>'Product Pictures',));?>
			<div id="product-list">
		
			</div>				
		<?php $this->endWidget();?>
	</div>

</div>
<div style="display: none;">
	<div id="uploadbox" style="height:330px;overflow:auto;">
		<?php $this->widget('ext.plupload.pluploadWidget',array(
			'url'=>$this->createUrl('file/upload',array('id'=>$model->pro_id,'uid'=>Yii::app()->user->id))
		));
		?>
	</div>
</div>

<?php $this->widget('ext.box.colorbox.colorboxWidget',array(
		'id'=>'.various1',
		'theme'=>'example1',
		'options'=>'width:"50%", inline:true, href:"#uploadbox",onClosed:function(){ load(); }'
));?> 


